package edu.szte.ovrt.datahandler.model;

import org.junit.Test;

import static org.junit.Assert.*;

public class ItemTest {

	@Test
	public void testKeyPropertyDefault() {
		final Item item = new Item(null, null);
		assertNull(item.getKey());
	}

	@Test
	public void testKeyPropertyGetSet() {
		final Item item = new Item(null, null);
		final String newKey = "testKey";
		item.setKey(newKey);
		assertEquals(newKey, item.getKey());
	}

	@Test
	public void testValuePropertyDefault() {
		final Item item = new Item(null, null);
		assertEquals("", item.getValue());
	}

	@Test
	public void testValuePropertyGetSet() {
		final Item item = new Item(null, null);
		final String newValue = "testValue";
		item.setValue(newValue);
		assertEquals(newValue, item.getValue());
	}

	@Test
	public void testEquals() {
		final Item item1 = new Item(null, "key", "value");
		final Item item2 = new Item(null, "key", "value");
		assertTrue(item1.equals(item2));
	}

	@Test
	public void testEqualsSetter() {
		final Item item1 = new Item(null, "key", "value");
		final Item item2 = new Item(null, null);
		item2.setKey("key");
		item2.setValue("value");
		assertTrue(item1.equals(item2));
	}

	@Test
	public void testEqualsDifferentKey() {
		final Item item1 = new Item(null, "key1", "value");
		final Item item2 = new Item(null, "key2", "value");
		assertFalse(item1.equals(item2));
	}

	@Test
	public void testEqualsDifferentValue() {
		final Item item1 = new Item(null, "key", "value1");
		final Item item2 = new Item(null, "key", "value2");
		assertFalse(item1.equals(item2));
	}

	@Test
	public void testEqualsDifferent() {
		final Item item1 = new Item(null, "key1", "value1");
		final Item item2 = new Item(null, "key2", "value2");
		assertFalse(item1.equals(item2));
	}

	@Test
	public void testEqualsNull() {
		final Item item1 = new Item(null, "key", "value");
		assertFalse(item1.equals(null));
	}

	@Test
	public void testEqualsOther() {
		final Item item1 = new Item(null, "key", "value");
		assertFalse(item1.equals(new Object()));
	}
}
